<style>
    /* 根据字数修改 */
    .layui-form-label {
        width: 90px;
    }

    .layui-form-item .layui-input-inline {
        width: 240px;
    }

    .layui-date .layui-form-select,
    .layui-date .layui-select-title {
        width: 115px;
        display: inline-block;
    }
</style>
<div class="layuimini-container layuimini-page-anim">
    <!-- 用于创建子页面 -->
    <div class="page-create"></div>

    <!-- page-main-create -->
    <!-- 用于显示 隐藏 -->
    <div class="layuimini-main page-main-create">

        <div class="title-row layuimini-title ">
            <div class="title-left">
                <h4><span>考勤汇总</span></h4>
            </div>
            <div class="title-right">
                <span class="title-right-text">
                    <button type="button" class="layui-btn  layui-btn-sm layui-btn-primary ml-3" lay-on="download"><i
                            class="layui-icon layui-icon-addition"></i>导出</button>
                </span>
            </div>
        </div>
        <div class="m-df">
            <form class="layui-form" action="" lay-filter="search-form">
                <div class="layui-form-item">
                    <div class="search-box-wrapper">
                        <div class="search-box-body">


                            <div class="layui-inline">
                                <label class="layui-form-label">周期</label>
                                <div class="layui-input-inline layui-date">

                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">2025</option>
                                        <option value="2">2024</option>
                                        <option value="3">2023</option>
                                        <option value="4">2022</option>
                                        <option value="5">2021</option>
                                        <option value="6">2020</option>
                                    </select>


                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="0">自定义周期</option>
                                        <option value="1">1月</option>
                                        <option value="2">2月</option>
                                        <option value="3">3月</option>
                                        <option value="4">4月</option>
                                        <option value="5">5月</option>
                                        <option value="6">6月</option>
                                        <option value="7">7月</option>
                                        <option value="8">8月</option>
                                        <option value="9">9月</option>
                                        <option value="10">10月</option>
                                        <option value="11">11月</option>
                                        <option value="12">12月</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline" style="width: 340px;">
                                    <input type="text" name="datePeriodStart" autocomplete="off" id="date_period"
                                        class="layui-input date-input ml-3" placeholder="请选择" />
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">姓名</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="nickname" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">岗位分类</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                        <option value="2">客户服务部负责人</option>
                                        <option value="3">安全员</option>
                                        <option value="4">运营调度</option>
                                        <option value="5">环卫保洁员</option>
                                        <option value="6">环卫主管</option>
                                        <option value="7">环卫司机</option>
                                        <option value="8">综合巡查主管</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">岗位</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                        <option value="2">客户服务部负责人</option>
                                        <option value="3">安全员</option>
                                        <option value="4">运营调度</option>
                                        <option value="5">环卫保洁员</option>
                                        <option value="6">环卫主管</option>
                                        <option value="7">环卫司机</option>
                                        <option value="8">综合巡查主管</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">网格</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">考勤方式</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">考勤状态</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">所属公司</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">所属部门</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="search-box-btns">
                            <div class="switch-wrapper" id="toggleFormBtn">
                                <span>展开</span>
                                <i class="layui-icon layui-icon-down" id="toggleIcon"></i>
                            </div>
                            <button type="submit" class="layui-btn layui-btn-sm" lay-submit
                                lay-filter="data-search-btn">查询</button>
                            <button type="reset" class="layui-btn  layui-btn-sm layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>


        <div class="section table-stripe">
            <div class="pb-4">
                <span class="pr-5">应出勤总天数：5281天</span>
                <span class="pr-5">应出勤总工时：41878.34小时</span>
                <span class="pr-5">实际出勤总天数：5253天</span>
                <span class="pr-5">实际出勤总工时：40950.18小时</span>
            </div>
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </div>

    </div>
</div>
<script>
    layui.use(['form', 'table', 'tabs', 'miniPage', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            tabs = layui.tabs,
            laydate = layui.laydate,
            layer = layui.layer,
            util = layui.util,
            element = layui.element,
            miniPage = layui.miniPage;
        /******************** 事件 start ********************/

        util.on('lay-on', {
            'download': function () {
                console.log("导出")
            }
        })
        /******************** 事件 end ********************/



        /******************** 渲染组件 start ********************/
        form.render('select'); //刷新select选择框渲染
        laydate.render({
            elem: '#date_period',
            range: true
        });
        /******************** 渲染组件 end ********************/

        table.render({
            elem: '#currentTableId',
            url: 'api/table.json',
            cols: [[
                { field: 'name', minWidth: 100, title: '姓名', rowspan: 2 },
                { field: 'sign', minWidth: 100, title: '手机号', rowspan: 2 },
                { field: 'score', minWidth: 80, title: '所属公司', rowspan: 2 },
                { field: 'classify', minWidth: 80, title: '网格', rowspan: 2 },
                { field: 'city', minWidth: 80, title: '所属部门', rowspan: 2 },
                { field: 'wealth', minWidth: 135, title: '岗位分类', rowspan: 2 },
                { field: 'time', title: '分类', minWidth: 150, rowspan: 2 },
                { field: 'time', title: '开始时间', minWidth: 150, rowspan: 2 },
                { field: 'businessNames', minWidth: 135, title: '结束时间', rowspan: 2 },
                { field: 'classify', minWidth: 135, title: '考勤方式', rowspan: 2 },
                { field: 'time', minWidth: 135, title: '出勤', colspan: 4 },
                { field: 'time', minWidth: 135, title: '离岗', colspan: 2 },
                { field: 'time', minWidth: 135, title: '迟到',colspan: 2  },
                { field: 'time', minWidth: 135, title: '早退',colspan: 2 },
                { field: 'time', minWidth: 160, title: '全天漏签到',colspan: 1  },
                { field: 'time', minWidth: 160, title: '半天漏签到',colspan: 1  },
                { field: 'time', minWidth: 135, title: '全天旷工',colspan: 1  },
            ],

            [
                { field: 'email', title: '应出勤天数', width: 100 },
                { field: 'sex', title: '应出勤工时', width: 130 },
                { field: 'sign', title: '实际出勤天数', width: 130 },
                { field: 'sign', title: '实际出勤工时', width: 130 },
                { field: 'email', title: '离岗次数', width: 100, rowspan: 2 },
                { field: 'sex', title: '离岗时长', width: 100 },
                { field: 'email', title: '迟到次数', width: 100, rowspan: 2 },
                { field: 'sex', title: '时长(分钟)', width: 100 },
                { field: 'email', title: '早退次数', width: 100, rowspan: 2 },
                { field: 'sex', title: '早退(分钟)', width: 100 },
                { field: 'email', title: '次数', width: 160, rowspan: 1 },
                { field: 'email', title: '次数', width: 160, rowspan: 1 },
                { field: 'email', title: '时长(小时)', width: 100, rowspan: 1 },
            ]


            ],

            //             <tr>
            //   <th lay-data="{checkbox:true}" rowspan="2"></th>
            //   <th lay-data="{field:'username', width:80}" rowspan="2">联系人</th>
            //   <th lay-data="{align:'center'}" colspan="3">地址</th>
            //   <th lay-data="{field:'amount'}" rowspan="2">数量</th>
            //   <th lay-data="{fixed: 'right', width: 160, align: 'center', toolbar: '#templet-demo-theads-tool'}" rowspan="2">操作</th>
            // </tr>
            // <tr>
            //   <th lay-data="{field:'province', width:100}">省</th>
            //   <th lay-data="{field:'city', width:100}">市</th>
            //   <th lay-data="{field:'zone', width:100}">区</th>
            // </tr>
            // cols: [[ // 表头
            //     // { field: 'id', title: 'ID', width: 80, fixed: 'left' },
            //     { field: 'username', title: '用户名', width: 120 ,rowspan: 2 },
            //     { align: 'center', title: '详细信息', colspan: 2  }, // 跨列的表头
            //     { align: 'center', title: '详细信息' }, // 跨列的表头
            //     { align: 'center', title: '详细信息' }, // 跨列的表头
            //     { fixed: 'right', title: '操作', width: 150, align: 'center', toolbar: '#barDemo' }
            // ], [
            //     { field: 'sex', title: '性别', width: 80 }, // 跨行的表头
            //     { field: 'sign', title: '签名', width: 200 } // 跨行的表头
            // ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            size: 'lg'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar事件监听
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {   // 监听添加操作
                var content = miniPage.getHrefContent('page/table/add.html');
                var openWH = miniPage.getOpenWidthHeight();

                var index = layer.open({
                    title: '添加用户',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: [openWH[0] + 'px', openWH[1] + 'px'],
                    offset: [openWH[2] + 'px', openWH[3] + 'px'],
                    content: content,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('currentTableId')
                    , data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            console.log('tool(currentTableFilter)====', obj)
            if (obj.event === 'edit') {
                var content = miniPage.getHrefContent('page/table/add.html');
                var openWH = miniPage.getOpenWidthHeight();

                var index = layer.open({
                    title: '编辑用户',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: [openWH[0] + 'px', openWH[1] + 'px'],
                    offset: [openWH[2] + 'px', openWH[3] + 'px'],
                    content: content,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('确认删除吗', function (index) {
                    obj.del();
                    layer.close(index);
                });
            } else if (obj.event === 'detail') {  // 监听详情操作
                miniPage.renderPageCreate(`page/laborOperations/laborJobManager/components/planDetail.html?id=${data.id}`)
            }
        });

        // 开启监听 折叠展开事件
        miniPage.listen()

    });
</script>